<div class="container">
    <div class="row">
        <div class="col-md-8">
            <div id="postlist">
                {% if posts %}
                    {% for post in posts %}
                        <div class="panel posts-list">
                            <div class="panel-heading">
                                <div class="text-center">
                                    <div class="row">
                                        <div class="col-sm-9">
                                            <h3 class="pull-left">{{post.title}}</h3>
                                        </div>
                                        <div class="col-sm-3">
                                            <h4 class="pull-right">
                                            <small>{{ moment(post.timestamp).fromNow() }}</small>
                                            </h4>
                                        </div>
                                    </div>
                                </div>
                                <div>
                                    <a href="{{ url_for('.user', username=post.author.username) }}">
                                        <img class="img-rounded profile-thumbnail" src="{{ post.author.gravatar(size=20) }}">
                                        {{post.author.username}}
                                    </a>
                                </div>
                            </div>
                            <div class="panel-body">
                                {% if post.body_html %}
                                    {{ post.body_html | safe }}
                                {% else %}
                                    {{ post.body }}
                                {% endif %}

                            </div>
                            <div class="panel-footer posts-list-footer">
                                {% if current_user == post.author %}
                                    <a href="{{ url_for('.edit', id=post.id) }}">
                                        <span class="label label-color">Edit</span>
                                    </a>
                                    {% elif current_user.is_administrator() %}
                                    <a href="{{ url_for('.edit', id=post.id) }}">
                                        <span class="label label-danger">Edit [Admin]</span>
                                    </a>
                                {% endif %}
                                 <a href="{{ url_for('.post', id=post.id) }}">
                                     <span class="label label-color">查看详情</span>
                                 </a>
                                 <a href="{{ url_for('.post', id=post.id) }}#comments">
                                    <span class="label label-color">{{ post.comments.count() }} Comments</span>
                                </a>
                            </div>
                        </div>
                    {% endfor %}
                {% endif  %}
        </div>
        </div>
    </div>
</div>
